﻿<%@ Page Language="C#" MasterPageFile="~/MangerPage.master" AutoEventWireup="true" CodeFile="Manger_Users.aspx.cs" Inherits="Manger_Users" Title="用户管理" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="pagetitle">用户检索</div>
    <asp:Label ID="Label1" runat="server" Text="用户名："></asp:Label>
    <asp:TextBox ID="userid" runat="server" Width="94px">%</asp:TextBox>&nbsp;
    <asp:Label ID="Label2" runat="server" Text="用户组："></asp:Label>&nbsp;<asp:DropDownList
        ID="usergroup" runat="server">
        <asp:ListItem Value="%">全部</asp:ListItem>
        <asp:ListItem Value="A">普通教师</asp:ListItem>
        <asp:ListItem Value="B">专业管理员</asp:ListItem>
        <asp:ListItem Value="C">系统管理员</asp:ListItem>
    </asp:DropDownList>
    <asp:Button ID="Button1" runat="server" Text="检索" OnClick="Button1_Click" /><br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="mytable"
        DataKeyNames="User_ID" DataSourceID="SqlDataSource1" OnRowDeleted="GridView1_RowDeleted" AllowPaging="True" PageSize="20" EmptyDataText="没有检索到记录！">
        <Columns>
            <asp:BoundField DataField="User_ID" HeaderText="用户名" ReadOnly="True" SortExpression="User_ID" />
            <asp:BoundField DataField="User_Name" HeaderText="姓名" SortExpression="User_Name" />
            <asp:BoundField DataField="Role_Name" HeaderText="角色" SortExpression="Role_Name" />
            <asp:BoundField DataField="User_LastLogin" HeaderText="上次登录" SortExpression="User_LastLogin" />
            <asp:BoundField DataField="User_LoginTimes" HeaderText="登录次数" SortExpression="User_LoginTimes" />
            <asp:TemplateField HeaderText="操作">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("User_ID", "Manger_UserDetail.aspx?userid={0}") %>'>编辑</asp:HyperLink>
                    &nbsp; &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" OnClientClick="return confirm('确定删除该用户么？')">删除</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Jxzy_Database %>"
        DeleteCommand="DELETE FROM [zyk_Users] WHERE [User_ID] = @User_ID" 
        SelectCommand="SELECT [User_ID], [User_Name], [User_LoginTimes], [User_LastLogin],[Role_Name] FROM [zyk_Users] inner join [zyk_Roles] on [zyk_Roles].[Role_ID]=[zyk_Users].[User_Role] WHERE ([User_Role] LIKE '%' + @User_role + '%') AND ([User_ID] LIKE '%' + @User_ID + '%')">
        <DeleteParameters>
            <asp:Parameter Name="User_ID" Type="String" />
        </DeleteParameters>

        <SelectParameters>
            <asp:ControlParameter ControlID="usergroup" Name="User_Role" PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="userid" Name="User_ID" PropertyName="Text" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

